<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<input type="button" value="get方式访问服务器" onclick="ajaxGet()"/><br/>
	<input type="button" value="post方式访问服务器" onclick="ajaxPost()"/><br/>
	<input type="button" value="ajax方式访问服务器" onclick="ajax()"/><br/>
	<script src="${pageContext.request.contextPath}/lib/jquery/jquery-1.11.1.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		function ajaxGet(){
			$.get("${pageContext.request.contextPath}/ajax",
				{"name":"张三","age":80},
				function(data) {
					alert("name:" + data.name + ",age:" + data.age);
				},
			    "json");
		}
		function ajaxPost(){
			$.post("${pageContext.request.contextPath}/ajax",
					{"name":"大哥","age":90},
					function(data){
						alert("name:" + data.name + ",age:" + data.age);
					},
					"json")
		}
	</script>
</body>
</html>